<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

</body>
<script type="text/javascript">
var BaseCalculator = function() {
    this.decimalDigits = 2;
};

BaseCalculator.prototype = {
    add: function(x, y) {
        return x + y;
    },
    subtract: function(x, y) {
        return x - y;
    }
};
var Calculator = function () {
    //为每个实例都声明一个税收数字
    this.tax = 5;
};
        
//Calculator.prototype = new BaseCalculator();
//Calculator.prototype = BaseCalculator.prototype; //这样你在Calculator的实例上就访问不到那个decimalDigits值了

var calc = new Calculator();
alert(calc.add(1, 1));
//BaseCalculator 里声明的decimalDigits属性，在 Calculator里是可以访问到的
alert(calc.decimalDigits); 
</script>
</html>